//Ceiling of the log-base 2 of a number
function integer clogb2;
  input [31:0] value;
  reg div2;
  begin
    div2 = value%2;
 	  for (clogb2 = 0; value>0; clogb2=clogb2+1)
      value = value>>1;
    clogb2 = (div2) ? clogb2 : clogb2 - 1;
  end
endfunction
